package com.ltkj.ticket.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.ticket.domain.TicVenuesConfig;
import com.ltkj.ticket.service.ITicVenuesConfigService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 场馆门票时间段配置Controller
 * 
 * @author ruoyi
 * @date 2023-08-30
 */
@Api(tags = "场馆门票时间段配置")
@RestController
@RequestMapping("/config")
public class TicVenuesConfigController extends BaseController
{
    @Autowired
    private ITicVenuesConfigService ticVenuesConfigService;

    /**
     * 查询场馆门票时间段配置列表
     */
    @ApiOperation("查询场馆门票时间段配置列表")
    @RequiresPermissions("ticket:config:list")
    @GetMapping("/list")
    public TableDataInfo list(TicVenuesConfig ticVenuesConfig)
    {
        startPage();
        List<TicVenuesConfig> list = ticVenuesConfigService.selectTicVenuesConfigList(ticVenuesConfig);
        return getDataTable(list);
    }

    /**
     * 导出场馆门票时间段配置列表
     */
    @ApiOperation("导出场馆门票时间段配置列表")
    @RequiresPermissions("ticket:config:export")
    @Log(title = "场馆门票时间段配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicVenuesConfig ticVenuesConfig)
    {
        List<TicVenuesConfig> list = ticVenuesConfigService.selectTicVenuesConfigList(ticVenuesConfig);
        ExcelUtil<TicVenuesConfig> util = new ExcelUtil<TicVenuesConfig>(TicVenuesConfig.class);
        util.exportExcel(response, list, "场馆门票时间段配置数据");
    }

    /**
     * 获取场馆门票时间段配置详细信息
     */
    @ApiOperation("获取场馆门票时间段配置详细信息")
    @RequiresPermissions("ticket:config:query")
    @GetMapping(value = "/{ticVenuesConfigId}")
    public AjaxResult getInfo(@PathVariable("ticVenuesConfigId") Long ticVenuesConfigId)
    {
        return success(ticVenuesConfigService.selectTicVenuesConfigByTicVenuesConfigId(ticVenuesConfigId));
    }

    /**
     * 新增场馆门票时间段配置
     */
    @ApiOperation("新增场馆门票时间段配置")
    @RequiresPermissions("ticket:config:add")
    @Log(title = "场馆门票时间段配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicVenuesConfig ticVenuesConfig)
    {
        return toAjax(ticVenuesConfigService.insertTicVenuesConfig(ticVenuesConfig));
    }

    /**
     * 修改场馆门票时间段配置
     */
    @ApiOperation("修改场馆门票时间段配置")
    @RequiresPermissions("ticket:config:edit")
    @Log(title = "场馆门票时间段配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TicVenuesConfig ticVenuesConfig)
    {
        return toAjax(ticVenuesConfigService.updateTicVenuesConfig(ticVenuesConfig));
    }

    /**
     * 删除场馆门票时间段配置
     */
    @ApiOperation("删除场馆门票时间段配置")
    @RequiresPermissions("ticket:config:remove")
    @Log(title = "场馆门票时间段配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ticVenuesConfigIds}")
    public AjaxResult remove(@PathVariable Long[] ticVenuesConfigIds)
    {
        return toAjax(ticVenuesConfigService.deleteTicVenuesConfigByTicVenuesConfigIds(ticVenuesConfigIds));
    }
}
